export const state = () => ({
    productId: ''
})

export const mutations = {
    setProductId(state, productId) {
        state.productId = productId
    }
}

export const actions = {
    getProductListByCategoryId({}, categoryId) {
        return this.$api.product.getProductListByCategoryId(categoryId).then((res) => {
            if(res.data.status === 'OK') {
                console.log(res)
                return Promise.resolve(res.data.data)
            }
            else {
                return Promise.reject(new Error(res.data.msg))
            }
        }, (error) => {
            return Promise.reject(error)
        }).catch((error) => {
            return Promise.reject(error)
        })
    },
    getProductByProductId({}, productId) {
        return this.$api.product.getProductByProductId(productId).then((res) => {
            if(res.data.status === 'OK') {
                return Promise.resolve(res.data.data)
            }
            else {
                return Promise.reject(new Error(res.data.msg))
            }
        }, (error) => {
            return Promise.reject(error)
        }).catch((error) => {
            return Promise.reject(error)
        })
    }
}